import React from 'react'
import {Link} from 'react-router-dom'

class SynchronizedSearch extends React.Component {
    goToDetails(e) {
        // console.log(e.target.innerText);
        this.props.turnVal(e.target.innerHTML)
        // this.props.history.push('/hot/bestMatch');
    }

    render() {
        // console.log(this.props);
        // 搜索到的数据
        let arr = this.props.SearchBox;
        let lis = '';
        try {
            lis = arr.map((item) => {
                return(
                    <li key={item.id} className='mxx_searchResult' onClick={this.goToDetails.bind(this)}>
                    <img src={require('../../assets/mxx_images/sousuo.png')} alt="" />
                    <Link className='span' to='/search/bestMatch'>{item.name}</Link>
                    </li>
                )
            })
        } catch (error) {
            alert('Error')
        }
        return(
            <div>
                <div className="mxx_SynchronizedSearch_1">搜索{this.props.state}</div>
                <ul className="mxx_SynchronizedSearch_2">
                    {lis}
                </ul>
            </div>
        )
    }
}

export default SynchronizedSearch